package com.jl.js.filepath;

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jl.smartcard.core.CorePluginRuntime;

public class ProjectFilePath implements IJsFilePath {
	private static final Logger log = LoggerFactory.getLogger(ProjectFilePath.class);
	private String name;
	private String parent;

	public ProjectFilePath(String name) {
		this.name = FilePathUtil.replaceAllAndRemoveEndSegment(name);
		this.parent = (String) CorePluginRuntime.getValue(CorePluginRuntime.PROJECT_CURRENT_ROOT_NO_SEGMENT);
		this.parent = FilePathUtil.replaceAllAndRemoveEndSegment(this.parent);
		log.info("parent is {}", this.parent);
		log.info("name is {}", this.name);
		
	}

	@Override
	public File getFile() {
		return new File(getAbsolutePath());
	}

	@Override
	public String getAbsolutePath() {
		return parent + name.substring(1);
	}

}
